package com.jason.xxl.timer;

import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TimerJob {
    //考虑后续 检测负载均衡 准备 执行者标识 端口好8090 8091 8092 8093...
    @Value("${server.port}")
    private String port;

    //定时任务执行的方法
    @XxlJob("job01")
    public void execute01() {
        String jobParam = XxlJobContext.getXxlJobContext().getJobParam();
        log.info("第一个任务执行了,执行端口:{},接收任务参数:{}", port, jobParam);
    }


    @XxlJob("job02")
    public void execute02() {
        log.info("第二个定时任务执行了,执行任务的进程端口:{}", port);
    }
}